package com.ycy.smartcourseselection.controller;

import cn.hutool.http.server.HttpServerRequest;
import com.ycy.smartcourseselection.common.PageResVO;
import com.ycy.smartcourseselection.common.ResData;
import com.ycy.smartcourseselection.dto.teacher.FindAllTchDTO;
import com.ycy.smartcourseselection.dto.teacher.FindPageTchDTO;
import com.ycy.smartcourseselection.dto.teacher.ForgetTchPwdDTO;
import com.ycy.smartcourseselection.dto.teacher.TeacherDTO;
import com.ycy.smartcourseselection.service.TeacherService;
import com.ycy.smartcourseselection.vo.teacher.HomePageVO;
import com.ycy.smartcourseselection.vo.teacher.TeacherVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Api(tags = "教师管理")
@RestController
@RequestMapping("/teacher")
public class TeacherController {
    @Resource
    private TeacherService teacherService;
    // @Resource
    // private StudentService studentService;
    // @Resource
    // private CourseService courseService;

    //分页查课程信息
    @PostMapping("/findPage")
    @ApiOperation(value="教师 -- 分页查",notes = "otherParams中的条件可选,支持联查")
    public ResData<PageResVO<TeacherVO>> findPageTch(@RequestBody FindPageTchDTO findPageTchDTO) {
        return teacherService.findPageTch(findPageTchDTO);
    }
    //增加或修改课程信息
    @PostMapping("/save")
    @ApiOperation(value="教师 -- 添加或修改",notes = "不带id为添加,否则为修改")
    public ResData<Boolean> saveTch(@RequestBody TeacherDTO teacherDTO) {
        return teacherService.saveTch(teacherDTO);
    }
    //假删除课程信息
    @DeleteMapping("/deleteByIds")
    @ApiOperation(value="教师 -- 批量辞退(假)",notes = "传删除课程的id数组")
    public ResData<Boolean> falseDeleteTchByIds(@RequestBody List<String> idList) {
        return teacherService.falseDeleteTchByIds(idList);
    }
    //根据学号查询个人信息
    @GetMapping("/getInfo")
    @ApiOperation(value="教师 -- 根据工号查询个人信息")
    public ResData<TeacherVO> getInfo(String workId) {
        return teacherService.getInfo(workId);
    }
    //重设密码
    @PostMapping("/modifyPwd")
    @ApiOperation(value="教师 -- 重设密码")
    public ResData<Boolean> modifyPwd(ForgetTchPwdDTO forgetTchPwdDTO) {
        return teacherService.modifyPwd(forgetTchPwdDTO);
    }
    //查询首页比图表统计数据
    @GetMapping("/homePage")
    @ApiOperation(value="教师 -- 查询首页统计图表数据")
    public ResData<HomePageVO> findHomePage(String workId) {
        return teacherService.findHomePage(workId);
    }
    //表格导入
    @PostMapping("/fileImport")
    @ApiOperation("教师 -- 表格导入")
    public ResData<Boolean> tchInfoImport(@RequestPart @ApiParam(value = "表格对象") MultipartFile file){
        return teacherService.tchInfoImport(file);
    }
    @GetMapping("/fileExport")
    @ApiOperation("教师 -- 表格导出")
    public void stuWorkExport(HttpServletResponse response,FindAllTchDTO findAllTchDTO) {
        teacherService.tchInfoExport(response, findAllTchDTO);
    }

}
